package com.itheima.health.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itheima.health.pojo.CheckGroup;
import com.itheima.health.vo.CheckGroupVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface CheckGroupMapper extends BaseMapper<CheckGroup> {
    @Insert("insert into t_checkgroup_checkitem values(#{gid},#{checkitemId})")
    void addGroupInfoAndCheckItemInfo(@Param("gid") int gid, @Param("checkitemId") Integer checkitemId);
 //  ArrayList  []
    @Select("select  CHECKITEM_ID  from t_checkgroup_checkitem  where CHECKGROUP_ID = #{gid} ")
    int[] findCheckItemIdsByGroupId(@Param("gid") int gid);

    @Delete("delete from t_checkgroup_checkitem where CHECKGROUP_ID =#{gid}")
    void deleteGroupAndCheckItemInfoByGid(@Param("gid") Integer gid);

    @Select("SELECT tc.id,tc.name,tc.remark " +
            "FROM t_setmeal_checkgroup tsc,t_checkgroup tc " +
            "where tsc.CHECKGROUP_ID = tc.ID " +
            "and tsc.SETMEAL_ID = #{sid}")
    List<CheckGroupVO> findCheckGroupInfoBySetmealId(@Param("sid") int sid);
}
